﻿using System.Diagnostics;

namespace 打字小游戏
{
    internal class Program
    {
        static void Main(string[] args)
        {
         
            //开始计时
            Stopwatch sw = new Stopwatch();
            sw.Start();
            Random rd = new Random();
            //定义次数
            int    n  =16;
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                //随机输出一个英文字母
                char hint = (char)rd.Next(65, 90);
                Console.WriteLine(hint);
                //无需区分键盘的大小写
                char direction = Console.ReadKey(true).KeyChar;
                direction = Char.ToUpper(direction);

                if (direction == hint)
                {
                    Console.Clear();
                }
                else
                {
                    count++;
                    Console.Clear();
                }
            }
            sw.Stop();
            //结束计时，输出时间
            TimeSpan ts = sw.Elapsed;
            double seconds = ts.TotalSeconds;
            Console.WriteLine("游戏运行时间为：" + seconds + "秒");
            Console.WriteLine("错误次数为：" + count);
        }
    }
}

